package com.nuvo.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;


@Entity
@Table(name = "MENU")
@XmlRootElement
@NamedQueries({
    
    @NamedQuery(name = "Menu.findAllOrderMenu", query = "SELECT m FROM Menu m order by m.raiz , m.orden"),
    @NamedQuery(name = "Menu.findByAction", query = "SELECT m FROM Menu m WHERE m.action = :action")
    })
public class Menu implements Serializable {

    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    
    @Size(min = 1, max = 100, message="debe ingresar un nombre")
    @Column(name = "NOMBRE")
    private String nombre;
    
    @Size(max = 100)
    @Column(name = "IMAGEN")
    private String imagen;
    
    @Size(max = 100)
    @Column(name = "URL")
    private String url;
    
    @Size(max = 100)
    @Column(name = "ACTION")
    private String action;
    
    @Column(name = "RAIZ")
    @NotNull(message = "Debe ingresar raiz")
    private Integer raiz;
    
    @Column(name = "ORDEN")
    @NotNull(message = "Debe ingresar un orden")
    private Integer orden;
    
    @Column(name = "CREATED")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    
    @Column(name = "UPDATED")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated;

    

    public Menu() {
    }

    public Menu(Integer id) {
        this.id = id;
    }

    

    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id; }

    public String getNombre() { return nombre; }
    public void setNombre(String nombre) { this.nombre = nombre;}

    public String getImagen() { return imagen; }
    public void setImagen(String imagen) { this.imagen = imagen; }

    public String getUrl() { return url; }
    public void setUrl(String url) { this.url = url; }

    public String getAction() { return action; }
    public void setAction(String action) { this.action = action; }

    public Integer getRaiz() { return raiz; }
    public void setRaiz(Integer raiz) { this.raiz = raiz; }

    public Integer getOrden() { return orden; }
    public void setOrden(Integer orden) { this.orden = orden; }

    public Date getCreated() { return created; }
    public void setCreated(Date created) { this.created = created; }

    public Date getUpdated() { return updated; }
    public void setUpdated(Date updated) { this.updated = updated; }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 17 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Menu other = (Menu) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.nombre == null) ? (other.nombre != null) : !this.nombre.equals(other.nombre)) {
            return false;
        }
        return true;
    }

    

   

    @Override
    public String toString() {
        return nombre + " (" + id + ")";
    }
    
}
